Promise._race = function (arr) {
	return new Promise(function (resolve, reject) {
		arr.forEach(item => {
			item.then(resolve,reject);
		})
	})
}
Promise._all = function (arr) {
	let count = arr.length;
	let result = [];
	return new Promise((resolve,reject)=>{
		arr.forEach((item,index) => {
			item.then(res=>{
				result[index] = res;
				if(--count <= 0){
					resolve(result);
				}
			}).catch(reject);
		})
	})
}
let promise1 = new Promise(res=>{
	setTimeout(()=>{
		res(1);
	},3000)
});
let promise2 = new Promise(res=>{
	setTimeout(()=>{
		res(2);
	},2000)
})
let promise3 = new Promise(res=>{
	setTimeout(()=>{
		res(3);
	},1000)
})
// Promise._race([promise1,promise2,promise3])
// 	.then(res=>{
// 		console.log(res);
// 	})
Promise._all([promise1,promise2,promise3])
	.then(res=>{
		console.log(res);
	})
	.catch(err=>{
		console.log(err);
	})